package com.ruoyi.consumer.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.consumer.domain.CCarousel;
import com.ruoyi.consumer.service.impl.CCarouselServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;


/**
 * @author: lizhouwei
 * @ date : 2023/10/23
 * @description:
 */
@Api(tags = "轮播图")
@RestController
@RequestMapping("/api/carousel")
public class CarouselController {

    @Autowired
    private CCarouselServiceImpl carouselService;



    @ApiOperation("查询轮播图列表")
    @GetMapping("/getCarouselLiset")
    public AjaxResult getCarouselLiset() {
        CCarousel carousel = new CCarousel();
        List<CCarousel> list = carouselService.selectCCarouselList(carousel);
        List<AjaxResult> resultlist = new ArrayList<>();
        for (CCarousel userCarousel : list) {
            AjaxResult carouselQuery = new AjaxResult();
            carouselQuery.put("carouselId", userCarousel.getCarouselId());
            carouselQuery.put("carouselName", userCarousel.getCarouselName());
            carouselQuery.put("image", userCarousel.getCarouselUrl());
            resultlist.add(carouselQuery);
        }
        return AjaxResult.success("success", resultlist);
    }
}
